package com.lyw.aop.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JDKInvocation implements InvocationHandler {
    /**
     * 目标对象, 被代理对象
     */
    private Object target;

    public JDKInvocation(Object target) {
        this.target = target;
    }

    //调用目标方法
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("我开始代理...");
        Object invoke = method.invoke(target, args);
        System.out.println("我结束代理");
        return invoke;
    }
}
